﻿Imports System.Data.SqlClient

Public Class cDescription

    Dim con As New SqlConnection(strcon)

    'Description Contract
    Public Function select_Description_Contract(ByVal ContractID As Long)
        Dim dt As New DataTable
        Dim oMain As New cMain
        dt = oMain.getData("SELECT DescriptionContractID,DescriptionName,UploadDate,UserID FROM tblDescriptionContract WHERE ContractID=N'" & ContractID & "'")
        Return dt
    End Function

    Public Function select_Description_Contract_byContractID(ByVal ContractID As Long) As DataTable
        Dim dt As New DataTable
        Dim oMain As New cMain
        dt = oMain.getData("SELECT DescriptionContractID,DescriptionName,UploadDate,UserID FROM tblDescriptionContract WHERE ContractID=N'" & ContractID & "'")
        Return dt
    End Function

    Public Function insert_Description_Contract(ByVal ContractID As Long, ByVal DescriptionName As String, ByVal UploadDate As Date, ByVal UserID As String) As Boolean
        Dim rv As Boolean = True
        Dim cmd As New SqlCommand
        cmd.CommandText = "INSERT INTO tblDescriptionContract(ContractID,DescriptionName,UploadDate,UserID) VALUES(@ContractID,@DescriptionName,@UploadDate,@UserID)"
        With cmd.Parameters
            .AddWithValue("@ContractID", ContractID)
            .AddWithValue("@DescriptionName", DescriptionName)
            .AddWithValue("@UploadDate", UploadDate)
            .AddWithValue("@UserID", UserID)
        End With
        cmd.Connection = con
        Try
            con.Open()
            cmd.ExecuteNonQuery()
        Catch ex As Exception
            rv = False
        Finally
            con.Close()
            cmd.Dispose()
        End Try
        Return rv
    End Function

    Public Function update_Description_Contract(ByVal DescriptionContractID As Long, ByVal DescriptionName As String) As Boolean
        Dim rv As Boolean = True
        Dim cmd As New SqlCommand
        cmd.CommandText = "UPDATE tblDescriptionContract SET DescriptionName=@DescriptionName WHERE DescriptionContractID=@DescriptionContractID"
        With cmd.Parameters
            .AddWithValue("@DescriptionContractID", DescriptionContractID)
            .AddWithValue("@DescriptionName", DescriptionName)
        End With
        cmd.Connection = con
        Try
            con.Open()
            cmd.ExecuteNonQuery()
        Catch ex As Exception
            rv = False
        Finally
            con.Close()
            cmd.Dispose()
        End Try
        Return rv
    End Function

    Public Function delete_Description_Contract(ByVal ContractID As Long) As Boolean
        Dim rv As Boolean = True
        Dim cmd As New SqlCommand
        cmd.CommandText = "DELETE FROM tblDescriptionContract WHERE ContractID=@ContractID"
        With cmd.Parameters
            .AddWithValue("@ContractID", ContractID)
        End With
        cmd.Connection = con
        Try
            con.Open()
            cmd.ExecuteNonQuery()
        Catch ex As Exception
            rv = False
        Finally
            con.Close()
            cmd.Dispose()
        End Try
        Return rv
    End Function
    'End Description Contract

    'Description CasePlaintiff
    Public Function select_Description_CasePlaintiff_byCaseID(ByVal CaseID As Long) As DataTable
        Dim dt As New DataTable
        Dim oMain As New cMain
        dt = oMain.getData("SELECT DescriptionCasePlaintiffID, DescriptionName, UploadDate, UserID FROM tblDescriptionCasePlaintiff WHERE CaseID=N'" & CaseID & "'")
        Return dt
    End Function

    Public Function insert_Description_CasePlaintiff(ByVal CaseID As Long, ByVal DescriptionName As String, ByVal UploadDate As Date, ByVal UserID As String) As Boolean
        Dim rv As Boolean = True
        Dim cmd As New SqlCommand
        cmd.CommandText = "INSERT INTO tblDescriptionCasePlaintiff(CaseID,DescriptionName,UploadDate,UserID) VALUES(@CaseID,@DescriptionName,@UploadDate,@UserID)"
        With cmd.Parameters
            .AddWithValue("@CaseID", CaseID)
            .AddWithValue("@DescriptionName", DescriptionName)
            .AddWithValue("@UploadDate", UploadDate)
            .AddWithValue("@UserID", UserID)
        End With
        cmd.Connection = con
        Try
            con.Open()
            cmd.ExecuteNonQuery()
        Catch ex As Exception
            rv = False
        Finally
            con.Close()
            cmd.Dispose()
        End Try
        Return rv
    End Function

    Public Function update_Description_CasePlaintiff(ByVal DescriptionCasePlaintiffID As Long, ByVal DescriptionName As String) As Boolean
        Dim rv As Boolean = True
        Dim cmd As New SqlCommand
        cmd.CommandText = "UPDATE tblDescriptionCasePlaintiff SET DescriptionName=@DescriptionName WHERE DescriptionCasePlaintiffID=@DescriptionCasePlaintiffID"
        With cmd.Parameters
            .AddWithValue("@DescriptionCasePlaintiffID", DescriptionCasePlaintiffID)
            .AddWithValue("@DescriptionName", DescriptionName)
        End With
        cmd.Connection = con
        Try
            con.Open()
            cmd.ExecuteNonQuery()
        Catch ex As Exception
            rv = False
        Finally
            con.Close()
            cmd.Dispose()
        End Try
        Return rv
    End Function

    Public Function delete_Description_CasePlaintiff(ByVal CaseID As Long) As Boolean
        Dim rv As Boolean = True
        Dim cmd As New SqlCommand
        cmd.CommandText = "DELETE FROM tblDescriptionCasePlaintiff WHERE CaseID=@CaseID"
        With cmd.Parameters
            .AddWithValue("@CaseID", CaseID)
        End With
        cmd.Connection = con
        Try
            con.Open()
            cmd.ExecuteNonQuery()
        Catch ex As Exception
            rv = False
        Finally
            con.Close()
            cmd.Dispose()
        End Try
        Return rv
    End Function
    'End Description CasePlaintiff

    'Description CaseDefendant
    Public Function select_Description_CaseDefendant_byCaseID(ByVal CaseID As Long) As DataTable
        Dim dt As New DataTable
        Dim oMain As New cMain
        dt = oMain.getData("SELECT DescriptionCaseDefendantID, DescriptionName, UploadDate, UserID FROM tblDescriptionCaseDefendant WHERE CaseID=N'" & CaseID & "'")
        Return dt
    End Function

    Public Function insert_Description_CaseDefendant(ByVal CaseID As Long, ByVal DescriptionName As String, ByVal UploadDate As Date, ByVal UserID As String) As Boolean
        Dim rv As Boolean = True
        Dim cmd As New SqlCommand
        cmd.CommandText = "INSERT INTO tblDescriptionCaseDefendant(CaseID,DescriptionName,UploadDate,UserID) VALUES(@CaseID,@DescriptionName,@UploadDate,@UserID)"
        With cmd.Parameters
            .AddWithValue("@CaseID", CaseID)
            .AddWithValue("@DescriptionName", DescriptionName)
            .AddWithValue("@UploadDate", UploadDate)
            .AddWithValue("@UserID", UserID)
        End With
        cmd.Connection = con
        Try
            con.Open()
            cmd.ExecuteNonQuery()
        Catch ex As Exception
            rv = False
        Finally
            con.Close()
            cmd.Dispose()
        End Try
        Return rv
    End Function

    Public Function update_Description_CaseDefendant(ByVal DescriptionCaseDefendantID As Long, ByVal DescriptionName As String) As Boolean
        Dim rv As Boolean = True
        Dim cmd As New SqlCommand
        cmd.CommandText = "UPDATE tblDescriptionCaseDefendant SET DescriptionName=@DescriptionName WHERE DescriptionCaseDefendantID=@DescriptionCaseDefendantID"
        With cmd.Parameters
            .AddWithValue("@DescriptionCaseDefendantID", DescriptionCaseDefendantID)
            .AddWithValue("@DescriptionName", DescriptionName)
        End With
        cmd.Connection = con
        Try
            con.Open()
            cmd.ExecuteNonQuery()
        Catch ex As Exception
            rv = False
        Finally
            con.Close()
            cmd.Dispose()
        End Try
        Return rv
    End Function

    Public Function delete_Description_CaseDefendant(ByVal CaseID As Long) As Boolean
        Dim rv As Boolean = True
        Dim cmd As New SqlCommand
        cmd.CommandText = "DELETE FROM tblDescriptionCaseDefendant WHERE CaseID=@CaseID"
        With cmd.Parameters
            .AddWithValue("@CaseID", CaseID)
        End With
        cmd.Connection = con
        Try
            con.Open()
            cmd.ExecuteNonQuery()
        Catch ex As Exception
            rv = False
        Finally
            con.Close()
            cmd.Dispose()
        End Try
        Return rv
    End Function
    'End Description CaseDefendant

    'Description CaseThirdParty
    Public Function select_Description_CaseThirdParty_byCaseID(ByVal CaseID As Long) As DataTable
        Dim dt As New DataTable
        Dim oMain As New cMain
        dt = oMain.getData("SELECT DescriptionCaseThirdPartyID, DescriptionName, UploadDate, UserID FROM tblDescriptionCaseThirdParty WHERE CaseID=N'" & CaseID & "'")
        Return dt
    End Function

    Public Function insert_Description_CaseThirdParty(ByVal CaseID As Long, ByVal DescriptionName As String, ByVal UploadDate As Date, ByVal UserID As String) As Boolean
        Dim rv As Boolean = True
        Dim cmd As New SqlCommand
        cmd.CommandText = "INSERT INTO tblDescriptionCaseThirdParty(CaseID,DescriptionName,UploadDate,UserID) VALUES(@CaseID,@DescriptionName,@UploadDate,@UserID)"
        With cmd.Parameters
            .AddWithValue("@CaseID", CaseID)
            .AddWithValue("@DescriptionName", DescriptionName)
            .AddWithValue("@UploadDate", UploadDate)
            .AddWithValue("@UserID", UserID)
        End With
        cmd.Connection = con
        Try
            con.Open()
            cmd.ExecuteNonQuery()
        Catch ex As Exception
            rv = False
        Finally
            con.Close()
            cmd.Dispose()
        End Try
        Return rv
    End Function

    Public Function update_Description_CaseThirdParty(ByVal DescriptionCaseThirdPartyID As Long, ByVal DescriptionName As String) As Boolean
        Dim rv As Boolean = True
        Dim cmd As New SqlCommand
        cmd.CommandText = "UPDATE tblDescriptionCaseThirdParty SET DescriptionName=@DescriptionName WHERE DescriptionCaseThirdPartyID=@DescriptionCaseThirdPartyID"
        With cmd.Parameters
            .AddWithValue("@DescriptionCaseThirdPartyID", DescriptionCaseThirdPartyID)
            .AddWithValue("@DescriptionName", DescriptionName)
        End With
        cmd.Connection = con
        Try
            con.Open()
            cmd.ExecuteNonQuery()
        Catch ex As Exception
            rv = False
        Finally
            con.Close()
            cmd.Dispose()
        End Try
        Return rv
    End Function

    Public Function delete_Description_CaseThirdParty(ByVal CaseID As Long) As Boolean
        Dim rv As Boolean = True
        Dim cmd As New SqlCommand
        cmd.CommandText = "DELETE FROM tblDescriptionCaseThirdParty WHERE CaseID=@CaseID"
        With cmd.Parameters
            .AddWithValue("@CaseID", CaseID)
        End With
        cmd.Connection = con
        Try
            con.Open()
            cmd.ExecuteNonQuery()
        Catch ex As Exception
            rv = False
        Finally
            con.Close()
            cmd.Dispose()
        End Try
        Return rv
    End Function
    'End Description CaseThirdParty

End Class
